<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.sql.*" %>
    <%@ page import="javax.sql.DataSource"%>
<%@ page import="javax.naming.InitialContext"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
System.out.println("网站根目录为"+application.getRealPath("/"));
 //模块变量定义开始
 String strsql          = ""; // 数据库查询语句
 String strname  ="";
 //Beans对象定义和初始化
 InitialContext ctx     = null;
 DataSource ds          = null;
 Connection conn        = null;
 Statement stmt         = null;
 ResultSet rs           = null;
 
try
{
 
 ctx  = new InitialContext(); 
 ds   = (DataSource) ctx.lookup("java:/MySqlDS");
 conn = ds.getConnection();

stmt = conn.createStatement(  ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
strsql ="select * from examinfo";
rs = stmt.executeQuery(strsql);
while(rs.next())
{
strname=rs.getString("ClassRoomName"); 
out.print(strname); 
}
 
}
catch (Exception e)
{
 System.out.println(request.getServletPath()+" error : " + e.getMessage());
}
finally {
conn.close();
}

%>
</body>
</html>